<!--
Date: 2025-08-13
Copyright (c) 2025 Industrial Software Feature Database
-->
<template>
  <el-dialog  v-if="props.dialogVisible" v-model="props.dialogVisible" title="查看全部文件" width="1200px" append-to-body :before-close="closeDialog">
    <div v-loading="loading">
      <div class="model-batch">
        <label for="">机型：</label><span>{{ modelNumber }}</span>
        <label for="">批次：</label><span>{{ batchNumber }}</span>
      </div>
      <ResultTreeTable v-loading="loading" v-if="treeData.length" :treeVo="treeData" :isDialog="true" />
    </div>
    <template #footer>
      <div class="dialog-footer" style="text-align: center;">
        <el-button type="primary" @click="closeDialog">关闭窗口</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup name="AllFileView">
import ResultTreeTable from './ResultTreeTable.vue';
import { getAllFileList } from '@/api/dataAcquisition';
const emit = defineEmits(['handleEvent']);
const loading = ref(false);
const props = defineProps(['id', 'dialogVisible']);
const treeData = ref([]);
const modelNumber = ref('');
const batchNumber = ref('');
const closeDialog = () => {
  emit('handleEvent', {type: 'cancel'});
};
const getAllFiles = () => {
  loading.value = true;
  getAllFileList({id: props.id}).then(res => {
    if (res.code === 200) {
      if (res.data) {
        treeData.value = [res.data];
        modelNumber.value = res.data.modelNumber;
        batchNumber.value = res.data.batchNumber;
      }
      loading.value = false;
    }
  }).catch(() => {
    loading.value = false;
  }).finally(() => {
    loading.value = false;
  });
}
onMounted(() => {
  props.id && getAllFiles();
});
</script>

<style lang="scss" scoped>
.model-batch {
  padding: 10px;
  span {
    margin-right: 20px;
  }
}
</style>
